package com.company.project.core;

/*
 * @Description:    响应结果生成工具
 * @Author:         brilliantzhao
 * @CreateDate:     2019/5/25 22:46
 * @UpdateUser:
 * @UpdateDate:     2019/5/25 22:46
 * @UpdateRemark:
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    /*
     * @Description: 成功返回，不带数据
     * @Author: brilliantzhao
     * @CreateDate: 2019/5/27 16:12
     * @Param:
     * @Return:
     */
    public static Result genSuccessResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    /*
     * @Description: 成功返回，带数据
     * @Author: brilliantzhao
     * @CreateDate: 2019/5/27 16:12
     * @Param:
     * @Return:
     */
    public static <T> Result<T> genSuccessResult(T data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    /*
     * @Description: 失败返回
     * @Author: brilliantzhao
     * @CreateDate: 2019/5/27 16:12
     * @Param:
     * @Return:
     */
    public static Result getFailResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }
}
